#Compilator
cc = gcc
compile_flags = -Wall
build_flags = -lm
#Sources and Objects
root_include_dir	:= ./include
root_source_dir		:= ./src/
objects			:= $(wildcard $(addsuffix *.c, $(root_source_dir)))
objects			:= $(objects:.cpp=.o)




#Executable file
prog_dir := ./bin/
program_name = $(prog_dir)bsort_test

#Delete files
ifdef SystemRoot
  rmdir = rd
  rmfile = del /s /q
  root_source_dir := $(subst /,\, $(root_source_dir))
  prog_dir := $(subst /,\, $(prog_dir))
else
  ifeq ($(shell uname), Linux)
    rmdir = rm -f 
    rmfile = rm -rf
  endif
endif



all:  $(program_name)

$(program_name) : dirs $(objects)
	$(cc) $(objects) -o $@  $(compile_flags) $(build_flags) $(addprefix -I, $(root_include_dir))

dirs :
	if not exist $(prog_dir) mkdir $(prog_dir)
 
.PHONY : clean clear
 
clean :
	if exist $(prog_dir) $(rmfile) $(prog_dir) & $(rmdir) $(prog_dir)
	$(rmfile) $(root_source_dir)*.o 
clear :
	$(rmfile) $(root_source_dir)*.o 
